<template>
  <div class="wrapper">
    <swiper :options="swiperOptions">
      <!--key值与v-for的绑定是在swiper-slide上面，而不是在swiper上-->
      <swiper-slide :key="item.id" v-for="item in list">
        <img :src="item.imgUrl" class="pic" alt="picture">
      </swiper-slide>
      <div class="swiper-pagination" slot="pagination"></div>
    </swiper>
  </div>
</template>

<script>
import {Swiper, SwiperSlide} from 'vue-awesome-swiper'
export default {
  name: 'HomeSwiper',
  props: {
    list: Array
  },
  components: {
    Swiper,
    SwiperSlide
  },
  data: function () {
    return {
      swiperOptions: {
        /* 分页器 */
        pagination: {
          /* 设置分页器（页码） */
          el: '.swiper-pagination',
          /* 设置可以根据分页器来翻页 */
          clickable: true,
          loop: true,
          initialSlide: 2,
          autoplay: {
            delay: 1000,
            stopOnLastSlide: false,
            disableOnInteraction: false
          }
        }
      }
    }
  }
}
</script>

<style lang="stylus" scoped>
.wrapper >>> .swiper-pagination-bullet-active
  background: white
.wrapper
  width: 100%
  height: 0
  overflow: hidden
  padding-bottom: 31.25%
  .pic
    width: 100%
</style>
